<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Configure your Farmbot account </title>
    <link rel="stylesheet" href="/styles.css">
    <script>
      function showPassword() {
          var x = document.getElementById("password");
          x.type = (x.type === "password") ? "text" : "password";
      }

      function toggleAdvancedSettings() {
        var advanced = document.getElementById("advancedSettings");
        advanced.hidden = !advanced.hidden
        document.getElementById("advancedSettingsTitle").className =
            advanced.hidden ? "expandable" : "expanded"
      }
    </script>
  </head>

  <body>
    <h1>Configure FarmBot</h1>
    <h2><%= subtitle %></h2>

    <div class="widget">
      <div class="widget-header">
        <h5>FarmBot Web App Account</h5>
      </div>
      <div class="widget-content">
        <form method=post action=configure_credentials>
          <fieldset>
            <label for="email">Email</label>
            <input value="<%= email %>" type="email" name="email" required></p>

            <label for="password">Password</label>
            <div class="password-input-group">
              <input value="<%= password %>" type="text" name="password" id="password" required>
              <img class="eye-icon" src="icon_eye.svg"
                onclick="showPassword()" title="Show password">
            </div>

            <label id="advancedSettingsTitle" class="expandable" for="advancedSettings"
              onclick="toggleAdvancedSettings()">Advanced</label>
            <div id="advancedSettings" hidden>
              <label for="server"> Server </label>
              <input value="<%= server %>" type="url" name=server required></p>
            </div>
          </fieldset>
      </div>
    </div>

    <%= double_check_warning %>

    <div class="button">
      <input type="submit" value="Finish">
    </div>
    </form>

  </body>

</html>
